package com.example.demo.strategy.version1;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @Name : com.example.demo.strategy.version1.Test
 * @Description : 描述
 * Created by cyd on 2021-05-24 15:15:43
 */
public class Test {
    private JPanel testLabel;
    private JLabel onePrice;
    private JLabel num;
    private JTextField numText;
    private JLabel total;
    private JTextField totalPriceText;
    private JButton countBtn;
    private JTextField onePriceText;

    public Test() {
        countBtn.addActionListener(new ActionListener() {
            /**
             * Invoked when an action occurs.
             *
             * @param e
             */
            @Override
            public void actionPerformed(ActionEvent e) {
                Double onePrice = Double.valueOf(onePriceText.getText());
                Double num = Double.valueOf(numText.getText());
                double totalPrice = onePrice * num;
                totalPriceText.setText(String.valueOf(totalPrice));
            }
        });
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("Test");
        frame.setContentPane(new Test().testLabel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}
